package com.joshondesign.sdljava.demo;

import com.joshondesign.sdljava.*;
import com.joshondesign.sdljava.gfx.*;

import java.io.File;

public class Demo4 implements SDLUtil.InitCallback {
    public static void main(String ... args) {
        SDLUtil.init(new Demo4());
    }
    public void callback() {
        try {
            Util.standard_init();
            Util.dump(SDL.SDL_GetVideoInfo());
            SDL_Surface surface = Util.createResizableWindow(800, 600);





            final SImage image = new SImage(new File("src/resources/andromeda.jpg"));
            final SFont font = new SFont(new File("src/resources/Junction.ttf"));
            Layer layer = new Layer(surface.getFormat());
            layer.add(new Node() {
                @Override
                public void draw(GFX gfx) {
                    gfx.setPaint(SColor.BLACK);
                    gfx.fillRect(0,0,800,600);
                    gfx.draw9Slice(image,
                            20,20, 20,20,
                            0,0,700,500);
                    gfx.setPaint(SColor.WHITE);
                    gfx.drawString(font,"webOS + Java", 50,200);
                }
            });


            Scene scene = new Scene(surface);
            scene.add(layer);
            scene.start();

        } catch (SDLException ex) {
            ex.printStackTrace();
            SDL.SDL_Quit();
            System.exit(1);
        }

    }

}
